/*
    KDE Plugin for 3D Office Environment
    Copyright (C) 2011  Till Merker

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef OFFICEENVKDEPLUGIN_H
#define OFFICEENVKDEPLUGIN_H



#include <kwineffects.h>
#include <kwinglutils.h>
#include <kshortcut.h>
#include <QObject>
#include <QQueue>

namespace OfficeEnv {
    class OfficeEnv;
}

namespace KWin
{
  
class GLRenderTarget;
class GLTexture;

class OfficeEnvKDEPlugin : public QObject, public Effect
    {
    Q_OBJECT
    public:
        OfficeEnvKDEPlugin();
        ~OfficeEnvKDEPlugin();

        virtual void prePaintScreen( ScreenPrePaintData& data, int time );
	void paintScreen( int mask, QRegion region, ScreenPaintData& data );
	virtual void postPaintScreen();
       
	virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
	virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
	
	virtual void grabbedKeyboardEvent( QKeyEvent *e ); 
        virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, 
            Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );

	virtual void reconfigure( ReconfigureFlags flags );
	
        static bool supported();
	
    public slots:
	void globalShortcutChanged( const QKeySequence& seq ); 
	void toggleActive();

    private:
        GLTexture* mTexture[32];
        GLRenderTarget* mRenderTarget[32];
	GLTexture* mTargetTexture;
	bool mValid;
	bool mActive;
	
	int mPaintingDesktop;
	int mSwitchingToDesktop;
	
	Window mInputWindow;
	bool mKeyboardGrab;
	int mActiveKeyAction;
	float mSensitivity;
	
	OfficeEnv::OfficeEnv *mOfficeEnv;
	
	KShortcut mShortcut; 
    };

} // namespace

#endif // OFFICEENVKDEPLUGIN_H

